package com.yangqi.net;

import java.io.*;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.StandardCharsets;

public class ServerClass {
    public static void main(String[] args)throws IOException {
        ServerSocket serverSocket = new ServerSocket(9999);
        Socket accept = serverSocket.accept();
        System.out.println(accept.getInetAddress()+"连接成功");
        InputStream bis = accept.getInputStream();
        byte[] bytes = new byte[1024];
        int len = 0;
        while((len = bis.read(bytes)) != -1){
            System.out.println(new String(bytes,0,len));
        }
        OutputStream bos = accept.getOutputStream();
        bos.write("连接成功，你好啊".getBytes());
        accept.shutdownOutput();

        bis.close();


    }
}
